<?php
/**
s声明一个类Db，用于演示单态模式的使用
*/
header("Content-Type: text/html; charset=utf-8");
   class DB{
   	     private static $obj = null;

   	     private function __construct(){
   	     	echo "连接数据库成功<br>";
   	     }

   	     static function getInstance(){
   	     	if(is_null(self::$obj))
   	     		self::$obj = new self();
   	         return self::$obj;
   	     }

   	     function query($sql){
   	     	echo $sql;
   	     }
   }

   $db = DB::getInstance();

   $db -> query("select * form user");
